package com.cloud.tsp.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cloud.api.domain.stats.Maintenance;
import com.cloud.api.domain.stats.MaintenanceRes;
import com.cloud.api.domain.stats.QueryMaintenance;
import com.cloud.api.domain.stats.RepairStation;
import com.cloud.mybatis.domain.TableDataInfo;
import com.cloud.tsp.mapper.MaintenanceMapper;
import com.cloud.tsp.service.IMaintenanceService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * <p>
 * OLAP 服务实现类
 * </p>
 *
 * @author haohaibo
 * @since 2023-12-01
 */
@Service("maintenanceService")
public class MaintenanceServiceImpl extends ServiceImpl<MaintenanceMapper, Maintenance> implements IMaintenanceService {

    @Resource
    private MaintenanceMapper maintenanceMapper;

    @Override
    public TableDataInfo<MaintenanceRes> selectMaintenanceCarList(QueryMaintenance para) {
        IPage<MaintenanceRes> page = new Page<>(para.getPage(), para.getPageSize());
        IPage<MaintenanceRes> data = maintenanceMapper.selectMaintenanceCarList(page, para);
        for (MaintenanceRes maintenanceRes : data.getRecords()) {
            maintenanceRes.setVin(StrUtil.hide(maintenanceRes.getVin(), 8, 11));
        }
        return TableDataInfo.build(data);
    }

    @Override
    public TableDataInfo<RepairStation> selectMaintenanceList(QueryMaintenance para) {
        IPage<RepairStation> page = new Page<>(para.getPage(), para.getPageSize());
        IPage<RepairStation> data = maintenanceMapper.selectMaintenanceList(page, para);
        return TableDataInfo.build(data);
    }
}